const server_url="http://localhost:8080/ebuy_2023rj2";
axios = axios.create({
    baseURL: server_url+'/api',//设置基本的请求路径，这样在实例中就不比在写
    headers:{
        //默认所有数据都是JSON传递
        "Content-Type":"application/json;charset=UTF-8",

    }
});
//为axios添加拦截器，即每次访问接口时都会调用
axios.interceptors.response.use(
    function (response){//拦截正常返回，即http状态码是200的情况
        const responseData=response.data;
        console.log("axios拦截器",responseData);
        if (responseData.code==401 ){
            alert(responseData.msg);
            parent.location.href="login.html"
        }
        return response;
    }
)